<div class="SipeiMain_r fr">
    <h2 class="clearfix fonts_18 height45 fontc_444"><?php echo $this->title; ?></h2>
    <div class="clearfix back_bgf border_3 border_c pr30 pt20 pb20 height32 fontc_666">
        <form class="clearfix pb10" action="<?php echo $this->createUrl('/problem/default/list') ?>" method="GET">
            <table with="100%">
                <tbody>
                    <tr>
                        <td width="134" align="right" class="pt10 pr2">所属考试项目：</td>
                        <td width="250" class="pt10">
                            <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                                <span class="fl select_shelter">
                                    <select class="fl fontc_666" name="exam_id" id="exam_id">
                                        <option value="0">请选择</option>
                                        <?php if ($examall): foreach ($examall as $one): ?>
                                                <option value="<?php echo $one['exam_id']; ?>" <?php
                                                if ($search['exam_id'] == $one['exam_id']) {
                                                    echo "selected";
                                                }
                                                ?>><?php echo $one['exam_term_name']; ?></option>
                                                        <?php
                                                    endforeach;
                                                endif;
                                                ?>
                                    </select>
                                </span>
                            </span>
                        </td>
                        <td width="103" align="right" class="pt10 pr2">所属科目：</td>
                        <td width="151" class="pt10">
                            <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                                <span class="fl select_shelter select_shelter2">
                                    <select class="fl fontc_666" name="subject_id" id="subject_id">
                                        <option value="0">请选择</option>
                                        <?php if ($subjectall): foreach ($subjectall as $one): ?>
                                                <option value="<?php echo $one['subject_id']; ?>" <?php
                                                if ($search['subject_id'] == $one['subject_id']) {
                                                    echo "selected";
                                                }
                                                ?>><?php echo $one['subject_name']; ?></option>
                                                        <?php
                                                    endforeach;
                                                endif;
                                                ?>
                                    </select>
                                </span>
                            </span>
                        </td>
                        <td align="right" width="126" class="pt10"><input type="submit" value="查询" class="b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12 cursor" /></td>
                    </tr>
                    <tr>
                        <td align="right" class="pt10 pr2">所属学校：</td>
                        <td class="pt10">
                            <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                                <span class="fl select_shelter">
                                    <select class="fl fontc_666" name="school_id" id="school_id">
                                        <option value="0">请选择</option>
                                        <?php if ($schoolall): foreach ($schoolall as $one): ?>
                                                <option value="<?php echo $one['school_id']; ?>" <?php
                                                if ($search['school_id'] == $one['school_id']) {
                                                    echo "selected";
                                                }
                                                ?>><?php echo $one['school_name']; ?></option>
                                                        <?php
                                                    endforeach;
                                                endif;
                                                ?>
                                    </select>
                                </span>
                            </span>
                        </td>
                        <td valign="top" align="right" class="pt10 pr2" >姓名：</td>
                        <td class="pt10">
                            <input type="text" value="<?php echo $search['username']; ?>" name="username" id="username" class="w100 pt5 pr5 pb5 pl5 height20 border_c border_3 fontc_666">
                        </td>
                    </tr>
                </tbody>
            </table>
        </form>
    </div>
    <div class="clearfix back_bgf border_c mt15 pt20 pb20">
        <div class="clearfix pb20 pl30 pr30">
            <span class="fl height32">是否全部生成：<input type="checkbox" id="checkall" onclick="checkall()"></span>
            <input type="button" onclick="allproblem();" value="生成全通帐号" class="fl b_a_n border_3 back_bgfb w100 ml20 height32 fontc_FFF fonts_12" />
            <input type="button" value="删除" onclick="delete_all()" class="fl b_a_n border_3 back_bgfb w80 ml20 height32 fontc_FFF fonts_12 cursor" />
        </div>
        <form>
            <table class="height40" width="100%">
                <thead class="back_bgf5 fontc_666">
                    <tr>
                        <th width="30" align="right" class="m_hr_t m_hr_b pr10"><input type="checkbox" class="checkboxs"></th>
                        <th width="75" align="center" class="m_hr_t m_hr_b pr10">姓名</th>
                        <th width="190" align="center" class="m_hr_t m_hr_b">考试项目</th>
                        <th width="110" align="center" class="m_hr_t m_hr_b">所属学校</th>
                        <th width="110" align="center" class="m_hr_t m_hr_b">全通帐号</th>
                        <th width="100" align="center" class="m_hr_t m_hr_b">全通密码</th>
                        <th width="110" align="center" class="m_hr_t m_hr_b">分配题号</th>
                        <th width="80" align="center" class="m_hr_t m_hr_b">操作</th>
                    </tr>
                </thead>
                <tbody class="fontc_444">
                    <?php
                    if ($data): foreach ($data as $one):
                            ?>
                            <tr>
                                <td align="right" class="m_hr_b fontc_666 pr10"><input type="checkbox" name="deleteAll[]" value="<?php echo $one['teacher_id']; ?>" class="checkbox" /></td>
                                <td align="center" class="m_hr_b fontc_666 pr10"><?php echo $one['teacher_name']; ?></td>
                                <td align="left" class="m_hr_b height22 pt8 pb8"><?php echo $one['exam_term_name']; ?></td>
                                <td align="center" class="m_hr_b height22 pt8 pb8"><?php echo $one['school_name']; ?></td>
                                <td align="center" class="m_hr_b height22 pt8 pb8"><?php echo $one['teacher_num']; ?></td>
                                <td align="center" class="m_hr_b height22 pt8 pb8"><?php echo $one['teacher_pswd']; ?></td>
                                <td align="left" class="m_hr_b height22 pt8 pb8"> <?php
                                    $str_name = "";
                                    if (isset($one['num_ids'])) {
                                        $sum = count($one['num_ids']);
                                        foreach ($one['num_ids'] as $key => $num) {
                                            $str_name .=$num['num_id'];
                                            if (($sum - 1) != $key) {
                                                $str_name .= "、";
                                            }
                                        }
                                    }
                                    echo $str_name;
                                    ?></td>
                                <td align="center" class="m_hr_b">
                                    <a onclick="editproblem(<?php echo $one['teacher_id']; ?>)" class="mr10 cursor"><img src="/themes/default/images/Sipei/edit.png" title="编辑"/></a>
                                    <a onclick="deleteproblem(<?php echo $one['teacher_id']; ?>, $(this))"><img src="/themes/default/images/Sipei/delate.png" title="删除" class="cursor" /></a>
                                </td>
                            </tr>
                            <?php
                        endforeach;
                    else:
                        ?>
                        <tr>
                            <td colspan='6' class="pl30">当前没有您要的数据存在!</td>
                        </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </form>
        <?php $this->renderPartial('//partial/partial_pager', array('pages' => $pages, "url" => $pageUrl)); ?>
    </div>
</div>

<script type="text/javascript" >
                var api;
                function deleteproblem(teacher_id, $this) {
                    $.dialog.confirm('确定删除吗', function() {
                        $.get('/problem/default/deleteproblem', {teacher_id: teacher_id}, function(data) {
                            if (data == 1) {
                                $this.parents("tr").remove();
                            } else {
                                $.dialog.alert("删除失败");
                            }
                        });
                    });
                }

                function delete_all() {
                    var aa = '';
                    $("input[name='deleteAll[]']:checkbox:checked").each(function() {
                        aa += $(this).val() + ',';
                    });
                    if (aa == '') {
                        $.dialog.alert("请选择要删除条目");
                        return false;
                    }
                    $.dialog.confirm('确定删除所选数据吗', function() {
                        aa += 0;

                        $.get('/problem/default/delete_all', {id: aa}, function(data) {
                            location.reload();
                        });
                    });
                }
                function editproblem(teacher_id)
                {
                    api = $.dialog({
                        id: 'testID2',
                        lock: true,
                        fixed: true,
                        title: "编辑",
                        width: 500,
                        height: 250,
                        max: false,
                        min: false
                    });
                    $.get('/problem/default/allproblemuseredit', {teacher_id: teacher_id, time: new Date()}, function(data) {
                        api.content(data);
                    });
                }
                function allproblem()
                {
                    if ($("#checkall").is(':checked') == true) {
                        var exam_id = $('#exam_id').val();
                        var subject_id = $('#subject_id').val();
                        var school_id = $('#school_id').val();
                        var username = $('#username').val();
                        api = $.dialog({
                            id: 'testID2',
                            lock: true,
                            fixed: true,
                            title: "全部生成全通帐号",
                            width: 580,
                            height: 350,
                            max: false,
                            min: false
                        });
                        $.get('/problem/default/allproblemuserall', {exam_id: exam_id, subject_id:subject_id,school_id:school_id,username:username}, function(data) {
                            api.content(data);
                        });

                    } else {
                        var ch = [];
                        $(".checkbox:checked").each(function() {
                            ch.push($(this).val())
                        })
                        if (ch == '') {
                            $.dialog.alert("请选择生成用户");
                            return false;
                        }

                        api = $.dialog({
                            id: 'testID2',
                            lock: true,
                            fixed: true,
                            title: "生成全通帐号",
                            width: 580,
                            height: 350,
                            max: false,
                            min: false
                        });
                        $.get('/problem/default/allproblemuser', {ch: ch, time: new Date()}, function(data) {
                            api.content(data);
                        });
                    }

                }
                $(function() {
                    $(".checkboxs").click(function() {
                        var checkedS = $(this).attr("checked");

                        if (checkedS) {

                            $(".checkbox").attr("checked", true)
                        } else {
                            $(".checkbox").removeAttr("checked")
                        }
                    })

                })

</script>